using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._DataManagementTools._Raster._OrthoMapping
{
    /// <summary>
    /// <para>Generate Point Cloud</para>
    /// <para>Computes 3D points from stereo pairs and outputs a point cloud as a set of LAS files.</para>
    /// <para>从立体对计算 3D 点，并将点云输出为一组 LAS 文件。</para>
    /// </summary>    
    [DisplayName("Generate Point Cloud")]
    public class GeneratePointCloud : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public GeneratePointCloud()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_mosaic_dataset">
        /// <para>Input Mosaic Dataset</para>
        /// <para><xdoc>
        ///   <para>The input mosaic dataset, which must have completed the block adjustment process and have a stereo model.</para>
        ///   <para>To block adjust the mosaic dataset, use the Apply Block Adjustment tool. To build a stereo model on the mosaic dataset, use the Build Stereo Model tool.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>输入镶嵌数据集，该数据集必须已完成块平差过程并具有立体模型。</para>
        ///   <para>要对镶嵌数据集进行块调整，请使用应用块调整工具。要在镶嵌数据集上构建立体模型，请使用构建立体模型工具。</para>
        /// </xdoc></para>
        /// </param>
        /// <param name="_matching_method">
        /// <para>Matching Method</para>
        /// <para><xdoc>
        ///   <para>The method used to generate 3D points.</para>
        ///   <bulletList>
        ///     <bullet_item>Extended terrain matching—A feature-based stereo matching in which the Harris operator is used in detecting feature points. Since less feature points are extracted, this method is fast and can be used for data with less terrain variations and detail.</bullet_item><para/>
        ///     <bullet_item>Semiglobal matching—Semi-Global Matching (SGM) produces points that are denser and have more detailed terrain information. It can be used for images of urban areas. This is more computational intensive than ETM.1</bullet_item><para/>
        ///     <bullet_item>Multi-view image matching—Multi-view image matching (MVM) is based on the SGM matching method followed by a fusion step in which the redundant depth estimations across a single stereo model are merged. It produces dense 3D points and is computationally efficient.2</bullet_item><para/>
        ///   </bulletList>
        ///   <para>References:
        ///   <bullet_item>Heiko Hirschmuller et al., "Memory Efficient Semi-Global Matching," ISPRS Annals of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume 1–3, (2012): 371–376.</bullet_item><para/>
        ///   <bullet_item>Hirschmuller, H. "Stereo Processing by Semiglobal Matching and Mutual Information." Pattern Analysis and Machine Intelligence, (2008).</bullet_item><para/>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>用于生成 3D 点的方法。</para>
        ///   <bulletList>
        ///     <bullet_item>扩展地形匹配 - 一种基于要素的立体匹配，其中使用 Harris 算子检测要素点。由于提取的特征点较少，因此此方法速度很快，可用于地形变化和细节较少的数据。</bullet_item><para/>
        ///     <bullet_item>半全局匹配 - 半全局匹配 （SGM） 生成更密集且具有更详细地形信息的点。它可用于城市地区的图像。这比 ETM 的计算密集度更高。</bullet_item><para/>
        ///     <bullet_item>多视图影像匹配—多视图影像匹配 （MVM） 基于 SGM 匹配方法，然后进行融合步骤，在该步骤中合并单个立体模型中的冗余深度估计。它产生密集的 3D 点，并且计算效率高。</bullet_item><para/>
        ///   </bulletList>
        /// <para>引用：
        ///   <bullet_item>Heiko Hirschmuller 等人，“Memory Efficient Semi-Global Matching”，ISPRS Annals of the Photogrammetry， Remote Sensing and Spatial Information Sciences，第 1-3 卷，（2012 年）：371-376。</bullet_item><para/>
        ///   <bullet_item>Hirschmuller， H. “半全局匹配和互信息的立体处理。”模式分析与机器智能，（2008）。</bullet_item><para/>
        ///   </para>
        /// </xdoc></para>
        /// </param>
        /// <param name="_out_folder">
        /// <para>Output LAS Folder</para>
        /// <para><xdoc>
        ///   <para>The folder used to store the output LAS files.</para>
        ///   <para>If this tool is run multiple times with the same input parameters, the output may be slightly different due to random sampling.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>用于存储输出 LAS 文件的文件夹。</para>
        ///   <para>如果使用相同的输入参数多次运行此工具，则由于随机抽样，输出可能会略有不同。</para>
        /// </xdoc></para>
        /// </param>
        /// <param name="_out_base_name">
        /// <para>Output LAS Base Name</para>
        /// <para>A string used as a prefix to formulate the output LAS file names. For example, if name is used as the base, the output files will be named name1.las, name2.las, and so on.</para>
        /// <para>用作前缀的字符串，用于制定输出 LAS 文件名。例如，如果使用 name 作为基文件，则输出文件将命名为 name1.las、name2.las 等。</para>
        /// </param>
        public GeneratePointCloud(object _in_mosaic_dataset, _matching_method_value _matching_method, object _out_folder, object _out_base_name)
        {
            this._in_mosaic_dataset = _in_mosaic_dataset;
            this._matching_method = _matching_method;
            this._out_folder = _out_folder;
            this._out_base_name = _out_base_name;
        }
        public override string ToolboxName => "Data Management Tools";

        public override string ToolName => "Generate Point Cloud";

        public override string CallName => "management.GeneratePointCloud";

        public override List<string> AcceptEnvironments => ["parallelProcessingFactor", "scratchWorkspace", "workspace"];

        public override object[] ParameterInfo => [_in_mosaic_dataset, _matching_method.GetGPValue(), _out_folder, _out_base_name, _object_size, _ground_spacing, _minimum_pairs, _minimum_area, _minimum_adjustment_quality, _maximum_diff_gsd, _maximum_diff_OP];

        /// <summary>
        /// <para>Input Mosaic Dataset</para>
        /// <para><xdoc>
        ///   <para>The input mosaic dataset, which must have completed the block adjustment process and have a stereo model.</para>
        ///   <para>To block adjust the mosaic dataset, use the Apply Block Adjustment tool. To build a stereo model on the mosaic dataset, use the Build Stereo Model tool.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>输入镶嵌数据集，该数据集必须已完成块平差过程并具有立体模型。</para>
        ///   <para>要对镶嵌数据集进行块调整，请使用应用块调整工具。要在镶嵌数据集上构建立体模型，请使用构建立体模型工具。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Mosaic Dataset")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_mosaic_dataset { get; set; }


        /// <summary>
        /// <para>Matching Method</para>
        /// <para><xdoc>
        ///   <para>The method used to generate 3D points.</para>
        ///   <bulletList>
        ///     <bullet_item>Extended terrain matching—A feature-based stereo matching in which the Harris operator is used in detecting feature points. Since less feature points are extracted, this method is fast and can be used for data with less terrain variations and detail.</bullet_item><para/>
        ///     <bullet_item>Semiglobal matching—Semi-Global Matching (SGM) produces points that are denser and have more detailed terrain information. It can be used for images of urban areas. This is more computational intensive than ETM.1</bullet_item><para/>
        ///     <bullet_item>Multi-view image matching—Multi-view image matching (MVM) is based on the SGM matching method followed by a fusion step in which the redundant depth estimations across a single stereo model are merged. It produces dense 3D points and is computationally efficient.2</bullet_item><para/>
        ///   </bulletList>
        ///   <para>References:
        ///   <bullet_item>Heiko Hirschmuller et al., "Memory Efficient Semi-Global Matching," ISPRS Annals of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume 1–3, (2012): 371–376.</bullet_item><para/>
        ///   <bullet_item>Hirschmuller, H. "Stereo Processing by Semiglobal Matching and Mutual Information." Pattern Analysis and Machine Intelligence, (2008).</bullet_item><para/>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>用于生成 3D 点的方法。</para>
        ///   <bulletList>
        ///     <bullet_item>扩展地形匹配 - 一种基于要素的立体匹配，其中使用 Harris 算子检测要素点。由于提取的特征点较少，因此此方法速度很快，可用于地形变化和细节较少的数据。</bullet_item><para/>
        ///     <bullet_item>半全局匹配 - 半全局匹配 （SGM） 生成更密集且具有更详细地形信息的点。它可用于城市地区的图像。这比 ETM 的计算密集度更高。</bullet_item><para/>
        ///     <bullet_item>多视图影像匹配—多视图影像匹配 （MVM） 基于 SGM 匹配方法，然后进行融合步骤，在该步骤中合并单个立体模型中的冗余深度估计。它产生密集的 3D 点，并且计算效率高。</bullet_item><para/>
        ///   </bulletList>
        /// <para>引用：
        ///   <bullet_item>Heiko Hirschmuller 等人，“Memory Efficient Semi-Global Matching”，ISPRS Annals of the Photogrammetry， Remote Sensing and Spatial Information Sciences，第 1-3 卷，（2012 年）：371-376。</bullet_item><para/>
        ///   <bullet_item>Hirschmuller， H. “半全局匹配和互信息的立体处理。”模式分析与机器智能，（2008）。</bullet_item><para/>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Matching Method")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _matching_method_value _matching_method { get; set; }

        public enum _matching_method_value
        {
            /// <summary>
            /// <para>Extended terrain matching</para>
            /// <para>Extended terrain matching—A feature-based stereo matching in which the Harris operator is used in detecting feature points. Since less feature points are extracted, this method is fast and can be used for data with less terrain variations and detail.</para>
            /// <para>扩展地形匹配 - 一种基于要素的立体匹配，其中使用 Harris 算子检测要素点。由于提取的特征点较少，因此此方法速度很快，可用于地形变化和细节较少的数据。</para>
            /// </summary>
            [Description("Extended terrain matching")]
            [GPEnumValue("ETM")]
            _ETM,

            /// <summary>
            /// <para>Semiglobal matching</para>
            /// <para>Semiglobal matching—Semi-Global Matching (SGM) produces points that are denser and have more detailed terrain information. It can be used for images of urban areas. This is more computational intensive than ETM.1</para>
            /// <para>半全局匹配 - 半全局匹配 （SGM） 生成更密集且具有更详细地形信息的点。它可用于城市地区的图像。这比 ETM 的计算密集度更高。</para>
            /// </summary>
            [Description("Semiglobal matching")]
            [GPEnumValue("SGM")]
            _SGM,

            /// <summary>
            /// <para>Multi-view image matching</para>
            /// <para>Multi-view image matching—Multi-view image matching (MVM) is based on the SGM matching method followed by a fusion step in which the redundant depth estimations across a single stereo model are merged. It produces dense 3D points and is computationally efficient.2</para>
            /// <para>多视图影像匹配—多视图影像匹配 （MVM） 基于 SGM 匹配方法，然后进行融合步骤，在该步骤中合并单个立体模型中的冗余深度估计。它产生密集的 3D 点，并且计算效率高。</para>
            /// </summary>
            [Description("Multi-view image matching")]
            [GPEnumValue("MVM")]
            _MVM,

        }

        /// <summary>
        /// <para>Output LAS Folder</para>
        /// <para><xdoc>
        ///   <para>The folder used to store the output LAS files.</para>
        ///   <para>If this tool is run multiple times with the same input parameters, the output may be slightly different due to random sampling.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>用于存储输出 LAS 文件的文件夹。</para>
        ///   <para>如果使用相同的输入参数多次运行此工具，则由于随机抽样，输出可能会略有不同。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output LAS Folder")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _out_folder { get; set; }


        /// <summary>
        /// <para>Output LAS Base Name</para>
        /// <para>A string used as a prefix to formulate the output LAS file names. For example, if name is used as the base, the output files will be named name1.las, name2.las, and so on.</para>
        /// <para>用作前缀的字符串，用于制定输出 LAS 文件名。例如，如果使用 name 作为基文件，则输出文件将命名为 name1.las、name2.las 等。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output LAS Base Name")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _out_base_name { get; set; }


        /// <summary>
        /// <para>Maximum Object Size (in meter)</para>
        /// <para>A search radius within which surface objects, such as buildings or trees, will be identified. It is the linear size in map units.</para>
        /// <para>识别表面物体（如建筑物或树木）的搜索半径。它是以地图单位表示的线性大小。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Maximum Object Size (in meter)")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double _object_size { get; set; } = 10;


        /// <summary>
        /// <para>DSM Ground Spacing (in meter)</para>
        /// <para><xdoc>
        ///   <para>The ground spacing, in meters, at which the 3D points are generated.</para>
        ///   <para>The default is five times the source image pixel size.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>生成 3D 点的地面间距（以米为单位）。</para>
        ///   <para>默认值为源图像像素大小的五倍。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("DSM Ground Spacing (in meter)")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double? _ground_spacing { get; set; } = null;


        /// <summary>
        /// <para>Number of Image Pairs</para>
        /// <para><xdoc>
        ///   <para>The number of pairs used to generate 3D points. The default value is a minimum of 2 image pairs.</para>
        ///   <para>Sometimes a location may be covered with many image pairs. In this case, the tool will order the pairs based on the various threshold parameters specified in this tool. The pairs with the highest scores will be used to generate the points.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>用于生成 3D 点的对数。默认值至少为 2 个图像对。</para>
        ///   <para>有时，一个位置可能会被许多图像对覆盖。在这种情况下，该工具将根据此工具中指定的各种阈值参数对对进行排序。得分最高的对将用于生成分数。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of Image Pairs")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double _minimum_pairs { get; set; } = 4;


        /// <summary>
        /// <para>Overlap Area Threshold</para>
        /// <para>Specify a minimum overlap threshold area that is acceptable, which is a percentage of overlap between a pair of images. Image pairs with overlap areas smaller than this threshold will receive a score of 0 for this criteria and will descend in the ordered list. The range of values for the threshold is from 0 to 1. The default threshold value is 0.6, which is equal to 60 percent.</para>
        /// <para>指定可接受的最小重叠阈值区域，即一对图像之间重叠的百分比。重叠面积小于此阈值的图像对将在此条件下获得 0 分，并将在有序列表中降序。阈值的值范围为 0 到 1。默认阈值为 0.6，等于 60%。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Overlap Area Threshold")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double _minimum_area { get; set; } = 0.6;


        /// <summary>
        /// <para>Adjustment Quality Threshold</para>
        /// <para>Specify the minimum adjustment quality that is acceptable. The threshold value will be compared to the adjustment quality value that is stored in the stereo model. Image pairs with an adjustment quality less than the specified threshold will receive a score of 0 for this criteria and will descend in the ordered list. The range of values for the threshold is from 0 to 1. The default value is 0.2, which is equal to 20 percent.</para>
        /// <para>指定可接受的最小调整质量。阈值将与存储在立体模型中的调整质量值进行比较。调整质量低于指定阈值的图像对将在此标准中获得 0 分，并将在有序列表中降序。阈值的值范围为 0 到 1。默认值为 0.2，等于 20%。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Adjustment Quality Threshold")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double _minimum_adjustment_quality { get; set; } = 0.2;


        /// <summary>
        /// <para>GSD Difference Threshold</para>
        /// <para>Specify the maximum allowable threshold for the ground sample distance (GSD) between two images in a pair. The resolution ratio between the two images will be compared to the threshold value. Image pairs with a ground sample ratio greater than this threshold will receive a score of 0 for this criteria and will descend in the ordered list. The default threshold ratio is 2.</para>
        /// <para>指定一对图像之间地面采样距离 （GSD） 的最大允许阈值。两个图像之间的分辨率将与阈值进行比较。地面采样率大于此阈值的影像对将在此标准中获得 0 分，并将在有序列表中降序。默认阈值比率为 2。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("GSD Difference Threshold")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double _maximum_diff_gsd { get; set; } = 2;


        /// <summary>
        /// <para>Omega/Phi Difference Threshold</para>
        /// <para>Specify the maximum threshold for the Omega\Phi difference between the two image pairs. The Omega values and Phi values for the image pairs are compared. Image pairs with an Omega or a Phi difference greater than this threshold will receive a score of 0 for this criteria and will descend in the ordered list. The default threshold difference for each comparison is 8.</para>
        /// <para>指定两个图像对之间 Omega\Phi 差异的最大阈值。比较图像对的 Omega 值和 Phi 值。Omega 或 Phi 差异大于此阈值的图像对将在此标准中获得 0 分，并将在有序列表中降序。每次比较的默认阈值差为 8。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Omega/Phi Difference Threshold")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double _maximum_diff_OP { get; set; } = 8;


        public GeneratePointCloud SetEnv(object parallelProcessingFactor = null, object scratchWorkspace = null, object workspace = null)
        {
            base.SetEnv(parallelProcessingFactor: parallelProcessingFactor, scratchWorkspace: scratchWorkspace, workspace: workspace);
            return this;
        }

    }

}